var TestSceneLayer=cc.Layer.extend({
	map:null,
	tilemap:null,
	player:null,
	flag:false,
	hudpad:null,
	ctor:function() {
		this._super();
		
	},
	init:function(){
		if ('touches' in sys.capabilities)
            this.setTouchEnabled(true);
        else if ('mouse' in sys.capabilities)
            this.setMouseEnabled(true);

		


		cc.SpriteFrameCache.getInstance().addSpriteFrames(s_firstchar_plist);
		cc.SpriteFrameCache.getInstance().addSpriteFrames(s_Yuki_plist);
		cc.SpriteFrameCache.getInstance().addSpriteFrames(s_Mario_plist);
		cc.SpriteFrameCache.getInstance().addSpriteFrames(s_Sparks_plist);


		var sprite=new MStateObj("FirstChar");
		g_control.registerMediator(sprite.cmdMgr);
		//g_cmdMgr=sprite.cmdMgr;

		var director = cc.Director.getInstance();
		var winsize= director.getWinSize();

		sprite.setPosition(winsize.width/2-200,150);
		this.player=sprite;

		this.map=new Map();
		this.map.init(0);
		this.addChild(this.map,0,1);
		this.map.setZoomPlayer(sprite);
		this.map.setPosition(cc.p(0,0));

		this.map.addChild(sprite);
		this.map.addStateObj(sprite);
        this.setTouchEnabled(true);



        sprite.setMap(this.map);

        //添加其他测试角色
        var enemy=new MStateObj("Yuki");
        enemy.setPosition(winsize.width/2+100,150);
        enemy.setMap(this.map);
        enemy.diretion=-1;
        enemy.country=1;
        this.map.addChild(enemy);
        this.map.addStateObj(enemy);

        enemy=new MStateObj("Mario");
        enemy.setPosition(winsize.width/2-250,150);
        enemy.setMap(this.map);
        enemy.diretion=-1;
        this.map.addChild(enemy);
        this.map.addStateObj(enemy);
        g_control.registerMediator(enemy.cmdMgr);

        //添加操作界面
        this.hudpad=HudLayer.create();
        this.addChild(this.hudpad,0);
	},
	onTouchesBegan:function(touch,event){
	},
	onTouchesMoved:function (touches, event) {
    },
    onTouchesEnded:function (touches, event) {
    },
    onTouchesCancelled:function (touches, event) {
       console.log("onTouchesCancelled");
    }
});

var TestScene=cc.Scene.extend({
	onEnter:function(){
		this._super();
		var layer=new TestSceneLayer();
		layer.init();
		this.addChild(layer);
	}
});